# nums=[1,2,3]
# nums=[1,1,1]
nums=[1,1000000000]
def is_equal(nums):
    cur_elem=nums[0]
    for i in range(len(nums)):
        if nums[i]!=cur_elem:
            return False
    return True
def max_index(nums):
    the_max=nums[0]
    the_index=0
    for i in range(len(nums)):
        if nums[i]>the_max:
            the_max=nums[i]
            the_index=i
    return the_index
def minMoves(nums):
    if is_equal(nums):
        return 0
    n=0
    while not is_equal(nums):
        the_index=max_index(nums)
        for i in range(len(nums)):
            if i!=the_index:
                nums[i]+=1
        n+=1
    return n
print(minMoves(nums))